package com.example.pool;

import java.util.concurrent.*;

/**
 * @author: dangwen
 * @createDate: 2021/6/16
 */
public class Demo01 {
    public static void main(String[] args) {
//            Thread t = new Thread(new Runnable(){
//                @Override
//                public void run(){
//                    ThreadLocal<Son> threadLocal1 = new ThreadLocal<>();
//                    threadLocal1.set(new Son());
//                    System.out.println(threadLocal1.get());
//                    ThreadLocal<Son> threadLocal2 = new ThreadLocal<>();
//                    threadLocal2.set(new Son());
//                    System.out.println(threadLocal2.get());
//                }});
//            t.start();
//            Lock lock = new ReentrantLock();
//            lock.tryLock();
//
//            TimeUnit unit;
//            BlockingQueue workQueue;
            ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(1, 5, 30, TimeUnit.SECONDS,
                    new LinkedBlockingQueue<Runnable>(), new ThreadFactory() {
                @Override
                public Thread newThread(Runnable r) {
                    return new Thread(r,"tomThread");
                }
            }, new ThreadPoolExecutor.AbortPolicy());

            Runnable runnable = new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName());
                }
            };

            poolExecutor.execute(runnable);
            poolExecutor.shutdown();

    }
}
